package Demo2;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/1/17
 * Time:17:38
 **/

class Person implements Cloneable{//接口什么都没有，叫做空接口，标记接口，标记当前这个类是可以被克隆的
    public String name;

    public Person(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class TestDemo3 {
    public static void main1(String[] args) throws CloneNotSupportedException {
        Person person1 = new Person("jubai");
        Person person2 = (Person) person1.clone();
        System.out.println(person1.name);
        System.out.println(person2.name);
    }
}
